package cate.common.table.item.gem.sheet;

import cate.common.table.ESheet;
import cate.common.table.item.gem.row.GemBaseRow;

import java.util.HashMap;
import java.util.Map;

public class GemBaseSheet extends ESheet<GemBaseRow> {
    private static final Map<Integer,Integer> gradeMap = new HashMap<>();

    @Override
    public String getSheetName() {
        return "宝石基础表";
    }

    @Override
    public void onRowCreated(GemBaseRow row) {
        if (row != null && row.gradeTid > 0) {
            gradeMap.put(row.gradeTid, row.id);
        }
    }

    public int getBackGradeId(int tid) {
        return gradeMap.getOrDefault(tid, 0);
    }

    public GemBaseRow getRow(int protoId, int level) {
        return getList().stream().filter(e -> e.protoId == protoId && e.level == level).findAny().orElse(null);
    }
}
